<template>
  <div class="paginate-main">
    <div class="paginate-l">
      <div :style="{ color: leftTextColor }">{{ leftText }}</div>
      <div v-if="showMore" style="margin-left:10px;color:#409eff;cursor: pointer;" @click="showStatistics">更多统计>></div>
    </div>
    <el-pagination
      background
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
      :current-page="page"
      :page-size="perPage"
      :page-sizes="pageSizes"
      @size-change="changeSize"
      @current-change="changePage"
    />
  </div>
</template>

<script>
export default {
  name: 'Paginate',
  props: {
    leftText: { type: String, default: null },
    leftTextColor: { type: String, default: null },
    showMore: { type: Boolean, default: false },
    total: { type: Number, default: null },
    page: { type: Number, default: null },
    perPage: { type: Number, default: null },
    pageSizes: {
      type: Array, default() {
        return [10, 20, 50, 100, 200, 500]
      }
    }
  },
  methods: {
    // 改变每页显示数量
    changeSize: function(per_page) {
      this.$emit('paginate-change', per_page, 'per_page')
    },
    // 改变当前列表页码
    changePage: function(page) {
      this.$emit('paginate-change', page, 'page')
    },
    showStatistics: function() {
      this.$emit('show-statistics')
    }
  }
}
</script>

<style scoped>
.paginate-main {
  display: flex;
  color: #606266;
  padding-top: 5px;
  line-height: 32px;
  text-align: right;
  font-size: 13px;
  justify-content: space-between;
}

@media (max-width: 600px) {
  .paginate-l {
    display: none;
  }
}
@media (min-width: 600px) {
  .paginate-l {
    display: flex;
  }
}
</style>
